package test.h0815;

import java.util.Scanner;

public class Main8 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int value = sc.nextInt();

        int i = 0;
        int j = 0;
        int sum = 0;
        int count = 0;
        while (i < n && j < n) {
            sum += arr[j];
            if (sum > value) {
                count = Math.max(j - i, count);
                sum=0; //sum重置为0
                i++;
                j=i;
            } else {
                j++;
            }
        }
        //万一是最后答案才是最大的，刚好到n弹出循环没来得及更新。
        count= Math.max(j - i, count);
        System.out.println(count);
    }
}
